package com.sajus.web.billing.ejb.data.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "promotion")
@NamedQueries({
	@NamedQuery(name = "Promotion.findAll", query = "SELECT promo FROM Promotion promo"),
	@NamedQuery(name = "Promotion.findCurrentIndex", query ="SELECT r FROM Promotion r WHERE r.id= ( SELECT max(d.id) FROM Promotion d )" )
	})
public class Promotion extends PersistentObject{

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;
	
	private String description;
	private String name;
	private int duration;
	private Date startDate;
	private Date endDate;
	
	@OneToMany( mappedBy = "promotion")
	private Set<PromoOffering> offerings;
	
	@Override
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getDuration() {
		return duration;
	}
	public void setDuration(int duration) {
		this.duration = duration;
	}
	public Date getStartDate() {
		return startDate;
	}
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	public Set<PromoOffering> getOfferings() {
		return offerings;
	}
	public void setOfferings(Set<PromoOffering> offerings) {
		this.offerings = offerings;
	}
	
}
